package com.itheima.HomeWork;

import java.util.Random;

public class HM10 {
    public static void main(String[] args) {
        String code = getRandomCode();
        System.out.println(code);
    }
    public static String getRandomCode() {

        StringBuilder sb = new StringBuilder();
        for (char ch = 'a'; ch <= 'z'; ch++) {
            sb.append(ch);
        }
        for (char ch = 'A'; ch <= 'Z'; ch++) {
            sb.append(ch);
        }
        for (char ch = '0'; ch <= '9'; ch++) {
            sb.append(ch);
        }
        Random r = new Random();
        String code = "";
        for (int i = 0; i < 4; i++) {
            int index = r.nextInt(sb.length());
            code += sb.charAt(index);
        }
        return code;
    }
}
